MarioBox2DController = function(gameObject, box2dbody, box2dsys , jumpPower) {
    Box2DController.call(this, gameObject, box2dbody, box2dsys , jumpPower);
};

MarioBox2DController.prototype = Object.create(Box2DController.prototype);

MarioBox2DController.prototype.run = function() {
    Box2DController.prototype.run.call(this);

    if (input.left) {
        if (this.gameObject.currAnimationName != "walk_h") {
            this.gameObject.animation.gotoAndPlay("walk_h");
            this.gameObject.currAnimationName = "walk_h";
        }
        this.gameObject.facingRight = false;
    } else if (input.right) {
        if (this.gameObject.currAnimationName != "walk") {
            this.gameObject.animation.gotoAndPlay("walk");
            this.gameObject.currAnimationName = "walk";
        }
        this.gameObject.facingRight = true;
    } else {
        /*ninguna tecla se esta presionando*/
        var vel = this.box2dbody.GetLinearVelocity();
        if (vel.y == 0.0) {
            /*si el cuerpo esta en el suelo (velocidad y es 0)*/
            vel.x *= 0.90;

            if (this.gameObject.facingRight) {
                if (this.gameObject.currAnimationName != "idle") {
                    this.gameObject.animation.gotoAndPlay("idle");
                    this.gameObject.currAnimationName = "idle";
                }
            } else {
                if (this.gameObject.currAnimationName != "idle_h") {
                    this.gameObject.animation.gotoAndPlay("idle_h");
                    this.gameObject.currAnimationName = "idle_h";
                }
            }
        } else {
            /*si el cuerpo esta saltando o cayendo (velocidad y != 0)*/
            if (this.gameObject.facingRight) {
                if (this.gameObject.currAnimationName != "jump") {
                    this.gameObject.animation.gotoAndPlay("jump");
                    this.gameObject.currAnimationName = "jump";
                }
            } else {
                if (this.gameObject.currAnimationName != "jump_h") {
                    this.gameObject.animation.gotoAndPlay("jump_h");
                    this.gameObject.currAnimationName = "jump_h";
                }
            }
        }
    }
};
//run
